package com.chenfan.process.util;


import com.chenfan.infra.context.TenantContextHolder;
import com.chenfan.infra.context.UserContextHolder;
import com.chenfan.infra.vo.UserVO;

import java.util.Objects;

public class TenantUtil {

    private TenantUtil(){}

    public static Long getTenantId() {
        UserVO userVo = UserContextHolder.getUserVo();
        if (Objects.nonNull(userVo)) {
            return userVo.getTenantId();
        }
        return TenantContextHolder.getTenantId();
    }

    public static String getCurrentUserName() {
        UserVO userVo = UserContextHolder.getUserVo();
        if (Objects.nonNull(userVo)) {
            return userVo.getRealName();
        }
        return "";
    }

    public static String defaultCurrentUserName() {
        UserVO userVo = UserContextHolder.getUserVo();
        if (Objects.nonNull(userVo)) {
            return userVo.getRealName();
        }
        return "系统";
    }

}
